<?php
include "../../inc/log/adsession.php";
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
	<title>修改密码</title>
</head>
<body>

<?php
include "../../inc/data/connAdmin.php";
$stuId = $_GET['stuid'];
$newPa = md5('12345678');
$sql = "select stupa from mamx_stu 
        where stuid = '$stuId'";
$stmt=$conn->prepare($sql);
$stmt->execute();
$stmt->bind_result($stuPa);
$stmt->store_result();
$stmt->fetch();
if($newPa == $stuPa){
  ?>
  <script type="text/javaScript">
   alert("已经是初始密码，无需重置！");
   history.back();
   </script>
  <?php
}
else{
  $sql = "update mamx_stu 
          set stupa = '$newPa' 
          where stuid = '$stuId'";
  $stmt=$conn->prepare($sql);
  $stmt->execute();
  if($stmt->affected_rows == 1){
    echo <<<END
    <script type="text/javaScript">
    alert('密码已修改成功！');
    location = "stuShow.php";
    </script>
END;
  }
}
?>



</body>
</html>